#ifndef __LIB_STRING_UTILS_H__
#define __LIB_STRING_UTILS_H__

#include "libutilsbase.h"
//#include "TStrings.h"

#if defined(WIN32)
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif

LIB_NS_BEGIN

class LIBAPI UStrConvUtils
{
public:
	//static tstring ToUpper(const tstring& value);
	static tstring ToUpper( const tstring& value );
	static tstring ToLower(const tstring& value);
	static tstring ToString(double val, uint16 precision = 6,uint16 width = 0,
		TCHAR fill = _T(' '),std::ios::fmtflags flags = std::ios::fmtflags(0) );
	static tstring ToString(int32 val, uint16 width = 0,TCHAR fill = _T(' '),
		std::ios::fmtflags flags = std::ios::fmtflags(0) );
	static tstring ToString(TCHAR* lpszFormat,...);
	static tstring ToString(bool val,bool YesNo = false);
	static double ToDouble(const tstring& val);
	static int32 ToInt(const tstring& val);
	static bool ToBool(const tstring& value);

	static std::string	 WstringToString(const std::wstring& str);
	
	static std::wstring StringToWstring(const std::string& str);
	static std::wstring StringToWstring(const char* str, int32 length);
	
	static tstring IPtoString(DWORD dwIp);
};

class LIBAPI UStrSetUtils
{
public:
	static tstring GetWhiteCharSet();
	static bool	IsDigits(const tstring& data);
	static bool BelongstoSet(TCHAR s ,const tstring& charset );
};

class LIBAPI UStrUtils
{
public:
	static bool IsNullorEmpty(const TCHAR* data);
	static bool IsValidBuffer(const TCHAR* lpsz, int32 nLength  = -1 );
	static bool Contains(const tstring& data,const tstring& tofind);
	static bool StartsWith(const tstring& data,const tstring& prefix);
	static bool EndsWith(const tstring& data,const tstring& suffix);
	static int32 CompareIgnoreCase(const tstring& data1,const tstring& data2 );
	static tstring TrimLeft (const tstring& s,const TCHAR* totrim = _T(" "));
	static tstring TrimRight(const tstring& s,const TCHAR* totrim = _T(" "));
	static tstring Trim(const tstring& s,const TCHAR* totrim = _T(" "));
	static tstring EraseAllChar(const tstring& s,TCHAR key);
	static tstring TrimLefTCHARSet(const tstring& data,const tstring& charset);
	static tstring TrimRighTCHARSet(const tstring& data,const tstring& charset);
	static void Split(tstrings* pdest, const tstring& data, 
		const tstring& delimiter = _T(" "));
	static tstring Join(const tstrings& vec,const tstring& szConnect);
	static tstring Replace(const tstring& data, const tstring& searched,
		const tstring& replaced);
	static tstring Replace(const tstring& data, TCHAR searched, TCHAR replaced);
	static tstring GetDomainFromUrl(const tstring& url);
};

class LIBAPI UString
{
public:
	static void FillChar(TCHAR* pdata,int32 len,TCHAR value);
	static void FillStart(TCHAR* pdata,const TCHAR* value);
	static void FillEnd(TCHAR* pdata,const TCHAR* value);

	static void PadLeft(TCHAR* pdata,int32 len,TCHAR value,int32 num);
	static void PadRight(TCHAR* pdata,int32 len,TCHAR value,int32 num);
	static void Copy(TCHAR* pdata,const TCHAR* value);
	static void Copy(TCHAR* pdata,const tstring& value);

	static bool IsNullorEmpty(TCHAR* pdata);
};

LIB_NS_END

#endif
